package com.cjg.javaBasics;

import javax.swing.plaf.BorderUIResource;
import java.util.Scanner;

public class Scannertest {
    public static void main(String[] arg){
//        Scanner scanner = new Scanner(System.in);
//        System.out.println("输入");
//        if(scanner.hasNext()){
//            String next = scanner.next();
//            System.out.println(next);
//        }

        t4();


    }

    public static void  te(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入");
        if(scanner.hasNextLine()){
            String next1 = scanner.nextLine();
            System.out.println(next1);

        }
    }

    public static void  te2(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入");
        String next1 = scanner.nextLine();
        System.out.println(next1);

    }
    public static void  te3(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入");
        if (scanner.hasNextInt()){
            String next1 = scanner.nextLine();
            System.out.println(next1);

        }else {
            System.out.println("error");
        }

        scanner.close();

    }
    //求多个数字的总和 ，平均数，每一个数以回车确认，非数字结束。
    public static void t4(){
        //设置数字代替总和与平均，参与之后运算
        int sum=0; int average=0;
        System.out.println("=============");
        Scanner scanner = new Scanner(System.in);
        for(int i =0;i<1000;i++){
            if(scanner.hasNextInt()){
                sum+=scanner.nextInt();
                average++;
            }else {
                System.out.println("总和："+sum);
                System.out.println("平均数："+sum/average);
                break;
            }
        }

    }

}
